//
//  TBCReadingListCell.m
//  待定
//
//  Created by BoyaLee on 15/11/9.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "TBCReadingListCell.h"
#import "TBCReadingList.h"

@interface TBCReadingListCell ()

@property (strong, nonatomic) BaseLabel *labelTitle;
@property (strong, nonatomic) UIImageView *imageViewCover;
@property (strong, nonatomic) BaseLabel *labelContent;

@end

@implementation TBCReadingListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self initReadingListCellViews];
        
    }
    
    return self;
    
}

- (void)initReadingListCellViews {
    
    self.labelTitle = [[BaseLabel alloc] initWithFrame:CGRectMake(20, 10, WIDTH - 75, 30)];
    self.labelTitle.font = [UIFont systemFontOfSize:18];
    [self addSubview:_labelTitle];
    
    self.imageViewCover = [[UIImageView alloc] initWithFrame:CGRectMake(20, 45, (WIDTH - 40) / 2, (HEIGHT - 64) * 0.25 - 64)];
    self.imageViewCover.layer.masksToBounds = YES;
    self.imageViewCover.layer.cornerRadius = 10;
    self.imageViewCover.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:_imageViewCover];
    
    self.labelContent = [[BaseLabel alloc] initWithFrame:CGRectMake(30 + (WIDTH - 40) / 2, 45, (WIDTH - 40) / 2 - 10, (HEIGHT - 64) * 0.25 - 64)];
    self.labelContent.font = [UIFont systemFontOfSize:15];
    self.labelContent.numberOfLines = 0;
    self.labelContent.lineBreakMode = NSLineBreakByWordWrapping;
    [self addSubview:_labelContent];
    
}

- (void)setReading:(TBCReadingList *)reading {
    
    _reading = reading;
    
    self.labelTitle.text = _reading.detail_title;
    [self.imageViewCover sd_setImageWithURL:[NSURL URLWithString:_reading.detail_coverimg] placeholderImage:[UIImage imageNamed:@"PlaceHolderImage@2x"]];
    self.labelContent.text = _reading.detail_content;
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
